// 箭头函数
<template>
  <div>
    <prism language="javascript">
      var x = v => v * v;
      console.log(typeof x);
      console.log(x(6));
      var x2 = () => Math.floor(Math.random() * 100); //随机数
      console.log(x2());
      var x2 = (n1, n2) => {
      //两个参数
      return parseInt(n1 + n2 / 2);
      };
      console.log(x2(18, 49));
      //基于
      function foo() {
      setTimeout(() => {
      console.log(this); //  this指向的是定义时使用的对象
      }, 1000);
      setTimeout(function() {
      console.log(this);
      }, 1000);
      }
      foo();
      new foo();
    </prism>
    <v-btn
      round
      color="success"
      @click="run"
    >
      RUN
    </v-btn>
  </div>
</template>

<script>
import Prism from "vue-prism-component";
export default {
  components: {
    Prism
  },
  methods: {
    run() {
      var x = v => v * v;
      console.log(typeof x);
      console.log(x(6));
      var x2 = () => Math.floor(Math.random() * 100); //随机数
      console.log(x2());
      var x2 = (n1, n2) => {
        //两个参数
        return parseInt(n1 + n2 / 2);
      };
      console.log(x2(18, 49));
      //基于
      function foo() {
        setTimeout(() => {
          console.log(this); //  this指向的是定义时使用的对象
        }, 1000);
        setTimeout(function() {
          console.log(this);
        }, 1000);
      }
      foo();
      new foo();
    }
  }
};
</script>